/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mwt.xml.xdbforms.dblayer.query.impl;

import java.util.List;
import mwt.xml.xdbforms.dblayer.query.Criteria;
import mwt.xml.xdbforms.dblayer.query.Criterion;

/**
 * Progetto Master Web Technology
 * @author Gianfranco Murador, Cristian Castiglia, Matteo Ferri
 */
public class CriteriaImpl implements Criteria {

    private Object[] values;
    private String sqlStatement = "";
    private String orderStmt = "";

    public CriteriaImpl() {
    }

    public String toSqlString() {
        return sqlStatement + orderStmt;
    }

    public void addCriterion(Criterion c) {

        values = c.getValues();

        for (int i = 0; i < values.length; i++) {
            Object object = values[i];
        }


        sqlStatement += c.toSQLString();
    }

    public void setMaxResults(int max) {
        sqlStatement += " LIMIT " + Integer.toString(max);
    }

    public void addOrder(String orderString) {
        orderStmt = orderString;
    }

    public int length() {
        return values.length;
    }

    public Object[] getValues() {
        return values;
    }
}
